package prefuseDemos;



import java.util.*;

import javax.swing.*;

import prefuse.data.Table;
import prefuse.util.ui.UILib;

public class anntest1 {

	private static Table generateTable() {
		Table table = new Table();

		// use a calendar for input of human-readable dates
		GregorianCalendar cal = new GregorianCalendar();

		// set up table schema
		table.addColumn("Date", Date.class);
		table.addColumn("BMI", double.class);
		table.addColumn("NBZ", int.class);
		table.addColumn("Insult", String.class);

		table.addRows(3);

		cal.set(2007, 11, 23);
		table.set(0, 0, cal.getTime());
		table.set(0, 1, 21.0);
		table.set(0, 2, 236);
		table.set(0, 3, "F");

		cal.set(2008, 6, 22);
		table.set(1, 0, cal.getTime());
		table.set(1, 1, 35.8);
		table.set(1, 2, 400);
		table.set(1, 3, "F");

		cal.set(2009, 3, 8);
		table.set(2, 0, cal.getTime());
		table.set(2, 1, 28.8);
		table.set(2, 2, 309);
		table.set(2, 3, "T");

		return table;
	}

	private static JComponent createVisualization(Table data) {
		return new JLabel("Hello World " + data.getInt(1, "NBZ"));
	}

	private static void createAndShowGUI(JComponent display) {
		JFrame frame = new JFrame();

		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setTitle("p r e f u s e | s c a t t e r   p l o t");

		frame.getContentPane().add(display);

		frame.pack();
		frame.setVisible(true);
	}

	public static void main(String[] args) {
		Locale.setDefault(Locale.US);
		UILib.setPlatformLookAndFeel();

		Table table = generateTable();
		final JComponent display = createVisualization(table);

		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				createAndShowGUI(display);
			}
		});
	}

}
